from ultralytics import YOLO

# Load a model
model = YOLO('yolov8n.pt')  # load an official model
model = YOLO('path/to/best.pt')  # load a custom trained model

# Export the model
# 导出到ONNX 或OpenVINO ，CPU 速度可提高 3 倍。
# 导出到TensorRT ，GPU 速度可提高 5 倍。

# 格式	        format参数	模型	                    元数据	论据
# PyTorch	        -	    yolov8n.pt	            ✅	    -
# TorchScript	torchscript	yolov8n.torchscript	    ✅	    imgsz, optimize
# ONNX	        onnx	    yolov8n.onnx	        ✅	    imgsz, half, dynamic, simplify, opset
# OpenVINO	    openvino	yolov8n_openvino_model/	✅	    imgsz, half, int8
# TensorRT	    engine	    yolov8n.engine	        ✅	    imgsz, half, dynamic, simplify, workspace
# CoreML	    coreml	    yolov8n.mlpackage	    ✅	    imgsz, half, int8, nms
# TF SavedModel	saved_model	yolov8n_saved_model/	✅	    imgsz, keras, int8
# TF 轻型	    tflite	    yolov8n.tflite	        ✅	    imgsz, half, int8
# TF 边缘TPU	    edgetpu	    yolov8n_edgetpu.tflite	✅	    imgsz
# TF.js	        tfjs	yolov8n_web_model/	        ✅	    imgsz, half, int8
# PaddlePaddle	paddle	yolov8n_paddle_model/	    ✅	    imgsz
# ncnn	ncnn	yolov8n_ncnn_model/	                ✅	    imgsz, half
model.export(format='onnx')